var o, e = require, t = module, n = exports, i = this && this.__extends || (o = function(t, e) {
    return (o = Object.setPrototypeOf || {
        __proto__: []
    } instanceof Array && function(t, e) {
        t.__proto__ = e;
    } || function(t, e) {
        for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]);
    })(t, e);
}, function(t, e) {
    function n() {
        this.constructor = t;
    }
    o(t, e), t.prototype = null === e ? Object.create(e) : (n.prototype = e.prototype, 
    new n());
}), a = this && this.__decorate || function(t, e, n, i) {
    var a, o = arguments.length, s = o < 3 ? e : null === i ? i = Object.getOwnPropertyDescriptor(e, n) : i;
    if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(t, e, n, i); else for (var c = t.length - 1; 0 <= c; c--) (a = t[c]) && (s = (o < 3 ? a(s) : 3 < o ? a(e, n, s) : a(e, n)) || s);
    return 3 < o && s && Object.defineProperty(e, n, s), s;
};

Object.defineProperty(n, "__esModule", {
    value: !0
});

var r = e("GameConfig"), s = e("GameData"), c = e("ActivityManager"), l = e("AudioManager"), d = e("DataManager"), u = e("EggsManager"), p = e("NewActivityManager"), h = e("UIManager"), f = e("WebManager"), g = e("Global"), m = e("MyButton"), y = e("PrefabView"), v = e("PersonView"), w = e("NewActivityItemView"), b = cc._decorator, P = b.ccclass, I = b.property, G = function(e) {
    function t() {
        var t = null !== e && e.apply(this, arguments) || this;
        return t.itemNode = null, t.layoutList = [], t.myButton = null, t.personView = null, 
        t.tips = null, t.path = "ui/newActivity/index/", t.data = [ {
            id: 21,
            type: c.ActivityType.FIRST,
            skinPath: t.path + "skin/0",
            titlePath: t.path + "title/0"
        }, {
            id: 22,
            type: c.ActivityType.SECOND,
            skinPath: t.path + "skin/1",
            titlePath: t.path + "title/1"
        }, {
            id: 23,
            type: c.ActivityType.THIRD,
            skinPath: t.path + "skin/2",
            titlePath: t.path + "title/2"
        }, {
            id: 24,
            type: c.ActivityType.FOURTH,
            skinPath: t.path + "skin/3",
            titlePath: t.path + "title/3"
        }, {
            id: 25,
            type: c.ActivityType.FIFTH,
            skinPath: t.path + "skin/4",
            titlePath: t.path + "title/4"
        }, {
            id: 26,
            type: c.ActivityType.SISTH,
            skinPath: t.path + "skin/5",
            titlePath: t.path + "title/5"
        }, {
            id: 27,
            type: c.ActivityType.SEVENTH,
            skinPath: t.path + "skin/6",
            titlePath: t.path + "title/6"
        } ], t;
    }
    return i(t, e), t.prototype.onClickBack = function() {
        l.default.getInstance().playAudio("按钮2"), f.default.getInstance().sentLog("点击新年活动返回按键"), 
        h.default.getInstance().showPnl("start"), this.hidePnl();
    }, t.prototype.onEnable = function() {
        cc.systemEvent.on("newActivityTips", this.tipsallback, this), cc.systemEvent.on("newActivityHint", this.hintCallback, this), 
        cc.systemEvent.on("newActivityTry", this.tryCallback, this), cc.systemEvent.on("newActivityCombine", this.combineCallback, this), 
        cc.systemEvent.on("newActivityCombineTry", this.combineCallback, this);
    }, t.prototype.onDisable = function() {
        cc.systemEvent.off("newActivityTips", this.tipsallback, this), cc.systemEvent.off("newActivityHint", this.hintCallback, this), 
        cc.systemEvent.off("newActivityTry", this.tryCallback, this), cc.systemEvent.off("newActivityCombine", this.combineCallback, this), 
        cc.systemEvent.off("newActivityCombineTry", this.combineCallback, this), e.prototype.onDisable.call(this);
    }, t.prototype.onDestroy = function() {
        e.prototype.onDestroy.call(this), h.default.getInstance().showPnl("start");
    }, t.prototype.start = function() {
        this.init();
    }, t.prototype.init = function() {
        this.data.every(function(t) {
            return -1 < u.default.getInstance().checkEggPerson(t.id);
        }) ? -1 == u.default.getInstance().checkEggPerson(28) ? (this.tips.active = !0, 
        this.myButton.init("newActivityCombine", "合成超级皮肤", m.BtnBgType.YELLOW, m.BtnIconType.NORMAL)) : (this.tips.active = !1, 
        this.myButton.init("newActivityCombineTry", "再用一次", m.BtnBgType.YELLOW)) : (this.tips.active = !1, 
        this.myButton.init("newActivityTips", "合成超级皮肤", m.BtnBgType.GRAY, m.BtnIconType.NORMAL));
        for (var t = 0; t < this.data.length; t++) {
            var e, n, i = Math.floor(t / 4);
            i < this.layoutList.length && ((n = (e = cc.instantiate(this.itemNode)).getComponent(w.default)) && (e.parent = this.layoutList[i], 
            e.active = !0, n.init(this.data[t])));
        }
        this.personView.init(-29, s.GD.gunIdx);
    }, t.prototype.tipsallback = function() {
        h.default.getInstance().loadPnl("hint").then(function(t) {
            t.contentLabel.string = "初一~初七，天天有新彩蛋";
        });
    }, t.prototype.hintCallback = function(t) {
        var e, t = t.target;
        t && t.parent && ((t = t.parent.getComponent(w.default)) && (e = p.default.getInstance().getHintConfig(t.id), 
        h.default.getInstance().loadPnl("hint").then(function(t) {
            t.titleLabel.string = e.t, t.contentLabel.string = e.c;
        })));
    }, t.prototype.tryCallback = function(t) {
        t = t.target;
        t && t.parent && ((t = t.parent.getComponent(w.default)) && this.doTry(t.id));
    }, t.prototype.combineCallback = function() {
        l.default.getInstance().playAudio("按钮2"), f.default.getInstance().sentLog("点击新年活动合成按键"), 
        s.GD.eggsHintState = 1, this.doTry(28), h.default.getInstance().hideAllPnl();
    }, t.prototype.combineTryCallback = function() {
        l.default.getInstance().playAudio("按钮2"), f.default.getInstance().sentLog("点击新年活动合成试用按键"), 
        this.doTry(28);
    }, t.prototype.doTry = function(t) {
        var e;
        f.default.getInstance().sentLog("试用彩蛋皮肤" + t), u.default.getInstance().updateEggPerson(t), 
        s.GD.personIdx = -1 - t, 28 == t ? ((e = u.default.getInstance().getDataPerson(28)) && (e.time = Date.now() + 6e4 * r.GC.newActivityPersonTime, 
        u.default.getInstance().setDataPerson(28, e)), g.G.tryPersonIdx = 128, g.G.tryPersonMap.set(g.G.tryPersonIdx, {
            id: g.G.tryPersonIdx,
            time: Date.now() + 6e4 * r.GC.newActivityPersonTime
        }), -1 < s.GD.skins.indexOf(s.GD.personIdx) && (s.GD.lastPersonIdx = s.GD.personIdx), 
        cc.systemEvent.emit("refresh_tryTime"), h.default.getInstance().loadPnl("newActivityReward")) : (g.G.tryPersonIdx = -1, 
        h.default.getInstance().loadPopPnl("egg_reward", {
            type: g.RewardType.SKIN,
            idx: t
        })), d.default.getInstance().save();
    }, a([ I(cc.Node) ], t.prototype, "itemNode", void 0), a([ I([ cc.Node ]) ], t.prototype, "layoutList", void 0), 
    a([ I(m.default) ], t.prototype, "myButton", void 0), a([ I(v.default) ], t.prototype, "personView", void 0), 
    a([ I(cc.Node) ], t.prototype, "tips", void 0), a([ P ], t);
}(y.default);

n.default = G;